<?php
declare(strict_types=1);

namespace mi7soft\core;
defined('MI7') or exit('No direct script access allowed');

class Config
{
    static $system_config = array();

    static function init()
    {
        global $configs;
        self::$system_config = $configs;
    }

    /**
     * @param $key
     * @param $default
     * @return mixed|null
     */
    static function get(string $key, string|int|float $default = null): string|array|object|null
    {
        if (isset(self::$system_config[$key])) {
            return self::$system_config[$key];
        } else {
            return $default;
        }
    }

    static function get_int(string $key): ?int
    {
        if (isset(self::$system_config[$key])) {
            return self::$system_config[$key];
        } else {
            throw new MainException($key . "不存在");
            return 0;
        }
    }
}